<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #demo {
            border: 1px solid black;
        }
    </style>
</head>
<body>
    <canvas id="demo"></canvas>
    <script>
        // 画布
        let canvas = document.getElementById('demo');
        // 绘制上下文
        let context = canvas.getContext('2d');
        const img = new Image();
        img.src = 'https://img2.baidu.com/it/u=3590113950,3364353300&fm=253&fmt=auto&app=138&f=JPEG?w=640&h=360';
        img.onload = function () {
            context.drawImage(img, 0, 0);
        }
    </script>
</body>
</html>